package com.sunny.t2;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        int m;
        Scanner scanner = new Scanner(System.in);
        m = scanner.nextInt();
        int n,k;
        while (m-- > 0){
            n = scanner.nextInt();
            k = scanner.nextInt();
            int d = n-k;
            if(k == 0){
                System.out.println(0+" " +0);
            }else if(k-1<d&&k>0){
                System.out.println(0+" "+(k-1));
            }else{
                System.out.println(0+" "+d);
            }
        }

    }

}
